<template>
  <div class="countdown-wrapper">
    <div class="countdown-container">
      <div class="countdown-item">
        <div class="countdown-number">{{ minutes }}</div>
        <div class="countdown-label">MIN</div>
      </div>
      <div class="countdown-item">
        <div class="countdown-number">{{ seconds }}</div>
        <div class="countdown-label">SEC</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';

const props = defineProps({
  totalSeconds: {
    type: Number,
    required: true
  }
});

const timeLeft = ref(props.totalSeconds);
let timerId;

const minutes = computed(() => String(Math.floor(timeLeft.value / 60)).padStart(2, '0'));
const seconds = computed(() => String(timeLeft.value % 60).padStart(2, '0'));

onMounted(() => {
  timerId = setInterval(() => {
    if (timeLeft.value > 0) {
      timeLeft.value--;
    } else {
      clearInterval(timerId);
    }
  }, 1000);
});

onUnmounted(() => {
  clearInterval(timerId);
});
</script>

<style scoped>
.countdown-wrapper {
  position: relative;
  z-index: 1;
}

.countdown-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.countdown-item {
  background: white;
  border-radius: 16px;
  padding: 18px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  min-width: 80px;
  text-align: center;
  position: relative;
  border: 2px solid transparent;
  background-clip: padding-box;
  transition: all 0.3s ease;
}

.countdown-item::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  padding: 2px;
  background: linear-gradient(135deg, #EF4444, #F87171);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.5;
}

.countdown-number {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, #EF4444, #DC2626);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown-label {
  font-size: 13px;
  color: #666;
  margin-top: 6px;
  font-weight: 500;
}
</style>
